/*
 *  Created on: 2011
 */

#include "Store.h"

Store* Store::create() {
	return new Store;
}

void Store::destroy(Store** ppInstance) {
	delete *ppInstance;
	*ppInstance = 0;
}

bool Store::empty() {
	pthread_mutex_lock(&_lock);
	bool empty = _pInput->empty();
	pthread_mutex_unlock(&_lock);
	return empty;
}

void Store::push(std :: string& rFilename) {
	pthread_mutex_lock(&_lock);
	_pInput->push_back(rFilename);
	pthread_mutex_unlock(&_lock);
}

std :: string Store::pop() {
	pthread_mutex_lock(&_lock);
	std :: string& element = _pInput->front();
	pthread_mutex_unlock(&_lock);
	return std :: string(element);
}

UINT Store::size() {
	pthread_mutex_lock(&_lock);
	UINT size = _pInput->size();
	pthread_mutex_unlock(&_lock);
	return size;
}

Store::Store() {
	_pInput = new std :: deque<std :: string>;
	pthread_mutex_init(&_lock, 0);
}

Store::~Store() {
	delete _pInput;
	_pInput = 0;
	pthread_mutex_destroy(&_lock);
}

